Supervised or unsupervised & model types
Contents
Supervised or unsupervised & model types¶
Aim(s) of this section 🎯¶
learn about the distinction between supervised & unsupervised machine learning
get to know the variety of potential models within each
Outline for this section 📝¶
supervised vs. unsupervised learning
supervised learning examples
unsupervised learning examples
A brief recap & first overview¶
Machine learning (ML) is the study of computer algorithms that can improve automatically through experience and by the use of data. It is seen as a part of artificial intelligence. Machine learning algorithms build a model based on sample data, known as “training data”, in order to make predictions or decisions without being explicitly programmed to do so. A subset of machine learning is closely related to computational statistics, which focuses on making predictions using computers; but not all machine learning is statistical learning. The study of mathematical optimization delivers methods, theory and application domains to the field of machine learning. Data mining is a related field of study, focusing on exploratory data analysis through unsupervised learning. Some implementations of machine learning use data and neural networks in a way that mimics the working of a biological brain.
https://en.wikipedia.org/wiki/Machine_learning
Let’s bring back our simplified graphical description that we introduced in the previous section:

So far we talked about how a model (M) can be utilized to obtain information (output) from a certain input.
The information requested can be manifold but roughly be situated on two broad levels:
specific task type - predicting clinical measures, behavior, demographics, other properties - segmentation - discover hidden structures - etc.
Lucky for us, the scikit-learn docs entail an amazing graphic outlining different model types that can be of tremendous help when deciding on a given analysis pipeline:

https://scikit-learn.org/stable/_static/ml_map.png
Here, we are going to add a bit more content to further stress the distinctions made above. First, the learning problem:

https://scikit-learn.org/stable/_static/ml_map.png
And second, the task type:

Learning problems - supervised vs. unsupervised¶
Based on these aspects we can and need to further specify our graphical description:

If we now also include task type we can basically describe things via a 2 x 2 design (leaving our graphical description for a moment):

Some primers using the example dataset¶
Now that we’ve gone through a huge set of definitions and road maps, let’s go away from this rather abstract discussions to the “real deal”.
Specifically, how these models behave in the wild. For this we’re going to sing the song “hello example dataset my old friend, I came to apply machine learning to you again.”. Just to be sure: we will use the example dataset we briefly explored in the previous section again to showcase how these models can be put into action, how they change/affect the questions one’s asking, and how to interpret the results.
At first, we’re going to load our input data, i.e., X again:
import numpy as np
data = np.load('MAIN2019_BASC064_subsamp_features.npz')['a']
data.shape
(155, 2016)
Just as a reminder: what we have in X here is a vectorized connectivity matrix containing 2016 features, which constitutes the correlation between brain region-specific time courses for each of 155 samples (participants).
As before, we can visualize our X to inspect it and maybe get a first idea if there might be something going on (please click on the + to see the code):
import plotly.express as px
from IPython.core.display import display, HTML
from plotly.offline import init_notebook_mode, plot
fig = px.imshow(data, labels=dict(x="features", y="participants"), height=800, aspect='None')
fig.update(layout_coloraxis_showscale=False)
init_notebook_mode(connected=True)
#fig.show()
plot(fig, filename = '../../../static/input_data.html')
display(HTML('../../../static/input_data.html'))
At this point we already need to decide on our learning problem:
do we want to use the information we already have (
labels) and thus conduct asupervised learninganalysis to predictY?do we want to find information we do not have (yet) and thus conduct an
unsupervised learninganalysis to e.g., findclustersin thedata?
Note
Please note